import request from "@/utils/request";

/**
 * 查询短信模板分页数据
 */
export function pages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/smsTemplate/pages",
    method: "get",
    params: params
  });
}

/**
 * 保存或修改模板数据
 * @param {*} data
 * @returns
 */
export function saveOrUpdate(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/smsTemplate/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据templateOid查询短信模板数据
 * @param {*} templateOid
 * @returns
 */
export function queryByTemplateOid(templateOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/smsTemplate/queryByTemplateOid",
    method: "get",
    params: {
      templateOid
    }
  });
}

/**
 * 根据业务主键删除短信模板数据
 * @param {*} templateOid
 * @returns
 */
export function deleteByTemplateOid(templateOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/smsTemplate/deleteByTemplateOid/${templateOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 通过templateCode校验是否存在，存在返回true，不存在返回false
 * @param {*} templateCode
 */
export function checkExistByTemplateCode(templateCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/smsTemplate/checkExistByTemplateCode/${templateCode}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
